﻿using NLog;
using System;
using System.Collections.Generic;
using System.Text;

namespace Oliving.Edge.Common.LogHelper.Nlog
{


    public static class NlogHelper
    {
        public static void saveNLog(InvokeLogModel model)
        {
            //ILogger ,
            LogEventInfo ei = new LogEventInfo();
            ei.Properties["InvokeResult"] = model.InvokeResult;
            ei.Properties["RequestUrl"] = model.RequestUrl;
            ei.Properties["MethodName"] = model.MethodName;
            ei.Properties["InvokeUserName"] = model.InvokeUserName;
            ei.Properties["InputJson"] = model.InputJson;
            ei.Properties["OutputJson"] = model.OutputJson;
            ei.Properties["BeginTime"] = model.BeginTime;
            ei.Properties["EndTime"] = model.EndTime;
            //ei.Message = "my test log message";
            //ei.Level = LogLevel.Trace;
            ei.LoggerName = "InvokeLogModel";

            Logger logger = LogManager.GetLogger("InvokeLogModel");

            logger.Trace(ei);
        }


        public static void LogSQL(InvokeLogSqlModel model)
        {
            //ILogger ,
            LogEventInfo ei = new LogEventInfo();

            ei.Message = model.ExecSQL + " => &#13;&#10;" + model.Paras;

            ei.LoggerName = "LogSQL";

            Logger logger = LogManager.GetLogger("LogSQL");

            logger.Trace(ei);
        }

    }

    public class InvokeLogModel
    {
        public string InvokeResult { get; set; }
        public string RequestUrl { get; set; }

        public string MethodName { get; set; }
        public string InvokeUserName { get; set; }
        public string InputJson { get; set; }
        public string OutputJson { get; set; }


        public DateTime BeginTime { get; set; }
        public DateTime EndTime { get; set; }


    }




    public class InvokeLogSqlModel
    {
        public string ExecSQL { get; set; }

        public string Paras { get; set; }


    }





}
